﻿@model Property4U.Models.Photo

@{
    ViewBag.Title = "Edit";
}

<div class="row">
    <!-- Page Header -->
    <div class="col-lg-12">
        <h1 class="page-header">@ViewBag.Title</h1>
    </div>
    <!--End Page Header -->
</div>

@using (Html.BeginForm(null, null, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
    
    <div class="form-horizontal">
        <h4>Photo</h4>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })
        @Html.HiddenFor(model => model.ID)

        <div class="form-group">
            @Html.LabelFor(model => model.PropertyID, "PropertyID", htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.DropDownList("PropertyID", (SelectList)ViewBag.PropertyIDList, String.Empty, htmlAttributes: new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.PropertyID, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.PhotoTitle, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.PhotoTitle, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.PhotoTitle, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.AltText, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.AltText, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.AltText, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Caption, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Caption, new { htmlAttributes = new { @class = "form-control" } })
                @Html.ValidationMessageFor(model => model.Caption, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.UploadedFrom, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <input type="file" accept="image/*" name="file" id="file" value="Choose File" class="form-control" />
                @Html.HiddenFor(model => model.UploadedFrom, new { id = "UploadedFrom" })
                @Html.HiddenFor(model => model.UploadedTo, new { id = "UploadedTo" })
                @Html.HiddenFor(model => model.Extension, new { id = "Extension" })
                @Html.HiddenFor(model => model.Size, new { id = "Size" })
                @Html.ValidationMessageFor(model => model.UploadedFrom, "", new { @class = "text-danger" })
                <input name="oldPhotoTitle" id="oldPhotoTitle" type="hidden" value="@Html.DisplayFor(model => model.PhotoTitle)" />
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.UploadedOn, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.UploadedOn, new { htmlAttributes = new { @class = "form-control", @readonly = "readonly" } })
                @Html.ValidationMessageFor(model => model.UploadedOn, "", new { @class = "text-danger" })
            </div>
        </div>

        @Html.HiddenFor(model => model.LastEdit, htmlAttributes: new { @Value = ViewBag.LastEdit })

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="Save" class="btn btn-default" />
            </div>
        </div>
    </div>
}

<div>
    @Html.ActionLink("Back to List", "Index")
</div>

@section scripts {
    <script type="text/javascript">
        jQuery('#file').change('input propertychange paste', function () {
            $("#UploadedFrom").val($(this).val());
        });
    </script>
}